﻿using System;
using System.Linq.Expressions;
using LF.Domain.Entities;

namespace LF.Domain.Services
{
	public interface IGlobalManagerService : IDomainService
    {
        /// <summary>
        /// 获取一行
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="id">主键</param>
        /// <returns></returns>
        T Get<T>(Guid id) where T : BaseEntity;
        /// <summary>
        /// 获取一行
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="where">条件</param>
        /// <returns></returns>
        T Get<T>(Expression<Func<T, bool>>? where = null) where T : BaseEntity;
        /// <summary>
        /// 插入一行
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="t"></param>
        /// <returns></returns>
        bool Insert<T>(T t) where T : BaseEntity;
        /// <summary>
        /// 插入多行
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="t"></param>
        /// <returns></returns>
        bool Insert<T>(IEnumerable<T> t) where T : BaseEntity;
        /// <summary>
        /// 删除一行
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="id"></param>
        /// <returns></returns>
        bool RealDelete<T>(Guid id) where T : BaseEntity;
        /// <summary>
        /// 条件删除
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="where">条件</param>
        /// <returns></returns>
        bool RealDeleteByWhere<T>(Expression<Func<T, bool>>? where = null) where T : BaseEntity;
        /// <summary>
        /// 逻辑删除
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="id"></param>
        /// <returns></returns>
        bool Delete<T>(Guid id) where T : BaseEntity;
        /// <summary>
        /// 逻辑删除
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="where">条件</param>
        /// <returns></returns>
        bool DeleteByWhere<T>(Expression<Func<T, bool>>? where = null) where T : BaseEntity;
        /// <summary>
        /// 更新一行
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="t"></param>
        /// <returns></returns>
        bool Update<T>(T t) where T : BaseEntity;
        /// <summary>
        /// 获取个数
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="where"></param>
        /// <returns></returns>
        long Count<T>(Expression<Func<T, bool>>? where = null) where T : BaseEntity;
        /// <summary>
        /// 获取列表
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="where"></param>
        /// <returns></returns>
        List<T> ToList<T>(Expression<Func<T, bool>>? where = null) where T : BaseEntity;
        /// <summary>
        /// 分页
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="index"></param>
        /// <param name="pageSize"></param>
        /// <param name="where"></param>
        /// <returns></returns>
        List<T> ToPageList<T>(int index, int pageSize, Expression<Func<T, bool>>? where = null) where T : BaseEntity;
        /// <summary>
        /// 分页
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <typeparam name="TMember"></typeparam>
        /// <param name="index"></param>
        /// <param name="pageSize"></param>
        /// <param name="order"></param>
        /// <param name="where"></param>
        /// <returns></returns>
        List<T> ToPageList<T,TMember>(int index, int pageSize, Expression<Func<T, TMember>> order, Expression<Func<T, bool>>? where = null) where T : BaseEntity;
        /// <summary>
        /// 分页
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <typeparam name="TMember"></typeparam>
        /// <param name="index"></param>
        /// <param name="pageSize"></param>
        /// <param name="order"></param>
        /// <param name="where"></param>
        /// <returns></returns>
        List<T> ToPageListDesc<T,TMember>(int index, int pageSize, Expression<Func<T, TMember>> order, Expression<Func<T, bool>>? where = null) where T : BaseEntity;

    }
}

